package com.home.rest;

import com.github.pagehelper.PageInfo;
import com.home.base.msg.ObjectRestResponse;
import com.home.base.msg.TableResultResponse;
import com.home.base.rest.BaseRestController;
import com.home.biz.ActivityBiz;
import com.home.biz.PhoneBiz;
import com.home.entity.ActivityPhone;
import com.home.entity.FetchPhone;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ：chenxf
 * @date ：Created in 2020/3/19 15:58
 * @description：
 * @modified By：
 * @version: $
 */
@RestController
@RequestMapping("activityFetch")
public class ActivityController extends BaseRestController<ActivityBiz, ActivityPhone> {


    @PostMapping("/fetch")
    public ObjectRestResponse fetch(@RequestParam(defaultValue = "0")String provName,@RequestParam(defaultValue = "0")String cityName,@RequestParam(defaultValue = "0000") String sNum, @RequestParam(defaultValue = "9999")String eNum, @RequestParam(defaultValue = "10")String tNum) {
        //  this.getCurrentId();//检验权限
        baseBiz.fetchOne(sNum,eNum,tNum,provName,cityName);
        return ObjectRestResponse.success("设置成功");
    }

    @PostMapping("/fetchEight")
    public ObjectRestResponse fetchEight(@RequestParam(defaultValue = "0")String provName,@RequestParam(defaultValue = "0")String cityName,@RequestParam(defaultValue = "0000") String sNum, @RequestParam(defaultValue = "9999")String eNum, @RequestParam(defaultValue = "10")String tNum) {
        //  this.getCurrentId();//检验权限
        baseBiz.fetchEight(sNum,eNum,tNum,provName,cityName);
        return ObjectRestResponse.success("设置成功");
    }

    @PostMapping("/fetchEightFen")
    public ObjectRestResponse fetchEightFen(@RequestParam(defaultValue = "0")String provName,@RequestParam(defaultValue = "0")String cityName,@RequestParam(defaultValue = "0000") String sNum, @RequestParam(defaultValue = "9999")String eNum, @RequestParam(defaultValue = "10")String tNum) {
        //  this.getCurrentId();//检验权限
        baseBiz.fetchEightFen(sNum,eNum,tNum,provName,cityName);
        return ObjectRestResponse.success("设置成功");
    }

    @PostMapping("/fetchJia")
    public ObjectRestResponse fetchJia(@RequestParam(defaultValue = "0")String provName,@RequestParam(defaultValue = "0")String cityName,@RequestParam(defaultValue = "0000") String sNum, @RequestParam(defaultValue = "9999")String eNum, @RequestParam(defaultValue = "10")String tNum) {
        //  this.getCurrentId();//检验权限
        baseBiz.fetchJia(sNum,eNum,tNum,provName,cityName);
        return ObjectRestResponse.success("设置成功");
    }

    @PostMapping("/fetchJiaSix")
    public ObjectRestResponse fetchJiaSix(@RequestParam(defaultValue = "0")String provName,@RequestParam(defaultValue = "0")String cityName,@RequestParam(defaultValue = "0000") String sNum, @RequestParam(defaultValue = "9999")String eNum, @RequestParam(defaultValue = "10")String tNum) {
        //  this.getCurrentId();//检验权限
        baseBiz.fetchJiaSix(sNum,eNum,tNum,provName,cityName);
        return ObjectRestResponse.success("设置成功");
    }

    @PostMapping("/fetchJiaEight")
    public ObjectRestResponse fetchJiaEight(@RequestParam(defaultValue = "0")String provName,@RequestParam(defaultValue = "0")String cityName,@RequestParam(defaultValue = "0000") String sNum, @RequestParam(defaultValue = "9999")String eNum, @RequestParam(defaultValue = "10")String tNum) {
        //  this.getCurrentId();//检验权限
        baseBiz.fetchJiaEight(sNum,eNum,tNum,provName,cityName);
        return ObjectRestResponse.success("设置成功");
    }

    @PostMapping("/fetchJiaOne")
    public ObjectRestResponse fetchJiaOne(@RequestParam(defaultValue = "0")String provName,@RequestParam(defaultValue = "0")String cityName,@RequestParam(defaultValue = "0000") String sNum, @RequestParam(defaultValue = "9999")String eNum, @RequestParam(defaultValue = "10")String tNum) {
        //  this.getCurrentId();//检验权限
        baseBiz.fetchJiaOne(sNum,eNum,tNum,provName,cityName);
        return ObjectRestResponse.success("设置成功");
    }

    @PostMapping("/fetchXin")
    public ObjectRestResponse fetchXin(@RequestParam(defaultValue = "0")String provName,@RequestParam(defaultValue = "0")String cityName,@RequestParam(defaultValue = "0000") String sNum, @RequestParam(defaultValue = "9999")String eNum, @RequestParam(defaultValue = "10")String tNum) {
        //  this.getCurrentId();//检验权限
        baseBiz.fetchXin(sNum,eNum,tNum,provName,cityName);
        return ObjectRestResponse.success("设置成功");
    }

    @PostMapping("/fetchYu")
    public ObjectRestResponse fetchYu(@RequestParam(defaultValue = "0")String provName,@RequestParam(defaultValue = "0")String cityName,@RequestParam(defaultValue = "0000") String sNum, @RequestParam(defaultValue = "9999")String eNum, @RequestParam(defaultValue = "10")String tNum) {
        //  this.getCurrentId();//检验权限
        baseBiz.fetchYu(sNum,eNum,tNum,provName,cityName);
        return ObjectRestResponse.success("设置成功");
    }

    @PostMapping("/fetchZs")
    public ObjectRestResponse fetchZs(@RequestParam(defaultValue = "0")String provName,@RequestParam(defaultValue = "0")String cityName,@RequestParam(defaultValue = "0000") String sNum, @RequestParam(defaultValue = "9999")String eNum, @RequestParam(defaultValue = "10")String tNum) {
        //  this.getCurrentId();//检验权限
        baseBiz.fetchZs(sNum,eNum,tNum,provName,cityName);
        return ObjectRestResponse.success("设置成功");
    }

    @GetMapping("/list")
    public TableResultResponse<ActivityPhone> list(int limit, int offset, String phoneNum, String cityName) {
        //  this.getCurrentId();//检验权限
        List<ActivityPhone> items = baseBiz.list(limit,offset,phoneNum,cityName);
        PageInfo<ActivityPhone> pageInfo = new PageInfo<>(items);
        return new TableResultResponse<>(Integer.parseInt(String.valueOf(pageInfo.getTotal())),
                limit, offset,
                items);
    }
}
